{% extends 'assets/base.html' %}
{% block content %}
<style>
    .col-sm-10 ul{list-style-type:none;line-height:33px;}
    .col-sm-10 li{float:left;margin-right:12px;text-align: left;}
    .col-sm-10 select  {
    background-color: #FFFFFF;
    background-image: none;
    border: 1px solid #CCCCCC;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
    color: #555555;
    display: block;
    font-size: 14px;
    height: 34px;
    line-height: 1.42857;
    padding: 6px 12px;
    transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;
    vertical-align: middle;
    width: 100%;
}
.invalid .form-control {
    background-color: #FFFFFF;
    background-image: none;
    border: 1px solid #ff0000;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
    color: #555555;
    display: block;
    font-size: 14px;
    height: 34px;
    line-height: 1.42857;
    padding: 6px 12px;
    transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;
    vertical-align: middle;
    width: 100%;
}

    .col-sm-10 .invalid{
    background-color: #FFFFFF;
    background-image: none;
    border: 1px solid #ff0000;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
    color: #555555;
    display: block;
    font-size: 14px;
    height: 34px;
    line-height: 1.42857;
    padding: 6px 12px;
    transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;
    vertical-align: middle;
    width: 100%;
}
</style>
<script type="text/javascript" src="/static/js/from_js/jquery.validVal.js"></script>
<link rel="stylesheet" href="/static/css/from_cs/jquery.validator.css">
<script type="text/javascript" src="/static/js/from_js/zh_CN.js"></script>

<script type="text/javascript">
 window.$ && $(function(){
//验证初始化
$('#signupForm').validator({
    //stopOnError:true,
    //timely: 2,
	theme: "yellow_right_effect",
    showOk: "",
    //自定义规则（PS：建议尽量在全局配置中定义规则，统一管理）
    rules: {
        check_node: [/^((l|i)-){0,1}(n-[a-z0-9]+|[a-z0-9]{1,10}\.[a-z0-9]{1,10}\.({% for i in env %}{% if forloop.last %}{{ i }}{% else %}{{ i }}|{% endif %}{% endfor %}))\.({% for i in idc_list %}{% if forloop.last %}{{ i }}{% else %}{{ i }}|{% endif %}{% endfor %})$/, '主机名不正确']
        //check_disk:[]
    },
    fields: {
        "node_name": {
            rule: "required;check_node;remote[/assets/select, node_name, csrfmiddlewaretoken]",
            tip: "输入主机名",
            ok: "",
            msg: {required: "主机名必须填写!"},
            data: {'data-ok':"主机名可以使用", 'data-msg-required': '主机名已正确'}
        },
        "hard_disk": {
            rule: "required;integer[+0]; range[20~60]",
            tip: "输入硬盘大小，默认为60G",
            ok: "",
            msg: {required: "输入硬盘大小，默认为60G!"}
        },
        "memory": {
            rule: "required;integer[+0]; range[1~32]",
            tip: "申请内存大小，最大32G",
            ok: "",
            msg: {required: "输入存大小，最大32G"}
        }
    }
    });

});
//代码高亮
window.highlight && highlight();
</script>


<form class="form-horizontal" action="" id="signupForm"  method="post" name="horizontal" role="form">
{#    <form class="exform form-horizontal" action="opadd" method="post" id="post_form" style="padding-top:8px;">#}
    {% csrf_token %}
    <div id="content-block" class="col-sm-11 col-md-5">
    <pre>红色为必填项</pre>
            {% if add_return %}
            <div class="alert alert-success alert-dismissable">
                 <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                <h4>
                    {{ hostname }} 添加成功!
                </h4>

            </div>
            {% endif %}
            <div class="form-group">
                 <label for="inputEmail3" class="col-sm-2 control-label">主机名</label>
                <div class="col-sm-10">
                    <input class="form-control"  name="node_name" data-rule="required" type="text"/>
                </div>
            </div>
            <div class="form-group">
                 <label for="inputEmail3" class="col-sm-2 control-label">cpu核数</label>
                <div class="col-sm-10">
                       {{ uf.core_num }}

                </div>
            </div>
            <div class="form-group">
                 <label for="inputEmail3" class="col-sm-2 control-label">硬盘</label>
                <div class="col-sm-10">
                    {% if edit_id.hard_disk %}
                    <input class="form-control" id="id_hard_disk" name="hard_disk"  value="{{ edit_id.hard_disk }}" type="text" />
                    {% else %}
                    <input class="form-control" id="id_hard_disk" name="hard_disk"   placeholder="默认以G为单位" type="text"  />
                    {% endif %}
                </div>
            </div>
            <div class="form-group">
                 <label for="inputEmail3" class="col-sm-2 control-label">内存</label>
                <div class="col-sm-10">
                    {% if edit_id.memory  %}
                    <input class="form-control" id="id_memory" name="memory" value="{{ edit_id.memory }}" type="text" />
                    {% else %}
                    <input class="form-control" id="id_memory" name="memory"  placeholder="默认以G为单位" type="text" />
                    {% endif %}
                </div>
            </div>
            <div class="form-group">
                 <label for="inputEmail3" class="col-sm-2 control-label">类型</label>
                <div class="col-sm-10">
                    <select id="id_usage"  data-rule="required" name="usage">
                        <option selected="selected" value="openstack">openstack</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                 <label for="inputEmail3" class="col-sm-2 control-label">系统</label>
                <div class="col-sm-10">
                    {{ uf.system }}
                </div>
            </div>
            <div class="form-group">
                 <label for="inputEmail3" class="col-sm-2 control-label">版本</label>
                <div class="col-sm-10">
                    {{ uf.system_cpuarch }}
                </div>
            </div>
            <div class="form-group">
                 <label for="inputEmail3" class="col-sm-2 control-label">业务</label>
                <div class="col-sm-10">
                  {{ uf.business }}
                </div>
            </div>
            <div class="form-group">
                 <label for="inputEmail3" class="col-sm-2 control-label">线上环境</label>
                <div class="col-sm-10">
                  {{ uf.env }}
                </div>
            </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                 <button type="submit" class="btn btn-success btn-block" name="_save">保存</button>
            </div>
{#            <div class="col-sm-3">#}
{#                 <button type="submit" class="btn btn-primary btn-block" name="_addanother">保存并增加另一个</button>#}
{#            </div>#}
        </div>
    </div>

</form>
{% endblock content %}




